function showChildInfo(data){
    console.log(data);
    var gen = '';
    if(data.gender == 'male'){
        gen = 'זכר';
    }
    else{
        gen = 'נקבה';
    }
    var secondParent = '';
    if (data.parent2_first_name != undefined){
        secondParent =                                 '<div class="row">\
                                    <div class="col-sm-6 pull-right" id="parent_2_name"><strong>\
' + data.parent2_first_name + ' ' + data.parent2_last_name + '\
                                    </strong></div>\
                                    <div class="col-sm-6" id="parent_2_info">\
' + data.parent2_phone_number + '\
<br>\
' + data.parent2_email_address + '\
                                    </div>\
                                </div>';
    }
    var content =             '<div class = "modal-dialog">\
                <div class = "modal-content">\
                    <div class = "modal-header">\
                        <div class="row">\
                            <div class="col-lg-6 pull-right" id="child_name">\
                                <h1>\
' + data.first_name + ' ' + data.last_name + '\
                                </h1>\
                            </div>\
                            <div class="col-lg-6 text-left" id="edit_btn">\
                                <a href="/editChild/?child_id=' + data.child_id + '" class = "btn btn-info"><i class="fa fa-pencil-square-o"></i> \
עריכה\
                                </a>\
                                <a class = "btn btn-danger" data-dismiss = "modal">&times;</a>\
                            </div>\
                        </div>\
                    </div>\
                    <div class = "modal-body">\
                        <div class="row">\
                            <div class="col-lg-6 pull-right">\
                                <div class="row">\
                                    <div class="col-sm-6 pull-right"><strong>\
תעודת זהות\
                                    </strong></div>\
                                    <div class="col-sm-6" id="child_id">\
' + data.child_id + '\
                                    </div>\
                                </div>\
                                <div class="row">\
                                    <div class="col-sm-6 pull-right"><strong>\
תאריך לידה\
                                    </strong></div>\
                                    <div class="col-sm-6" id="date_of_birth">\
' + data.date_of_birth + '\
                                    </div>\
                                </div>\
                                <div class="row">\
                                    <div class="col-sm-6 pull-right"><strong>\
מין\
                                    </strong></div>\
                                    <div class="col-sm-6" id="gender">\
' + gen + '\
                                    </div>\
                                </div>\
                                <div class="row">\
                                    <div class="col-sm-6 pull-right"><strong>\
טלפון\
                                    </strong></div>\
                                    <div class="col-sm-6" id="phone_number">\
' + data.phone_number + '\
                                    </div>\
                                </div>\
                                <div class="row">\
                                    <div class="col-sm-6 pull-right"><strong>\
כתובת\
                                    </strong></div>\
                                    <div class="col-sm-6" id="address">\
' + data.address + '\
                                    </div>\
                                </div>\
                                <br>\
                                <div class="row">\
                                    <div class="col-sm-6 pull-right" id="parent_1_name"><strong>\
' + data.parent1_first_name + ' ' + data.parent1_last_name + '\
                                    </strong></div>\
                                    <div class="col-sm-6" id="parent_1_info">\
' + data.parent1_phone_number + '\
<br>\
' + data.parent1_email_address + '\
                                    </div>\
                                </div>\
<br>' + secondParent + '</div>\
                            <div class="col-lg-6" id="child_img">\
                                <img src="static/img/default.jpg" alt="child.child_id" class="img-rounded pull-left">\
                            </div>\
                        </div>\
                    </div>\
                    <div class = "modal-footer" id="private_msg">\
                        <a href="/addMessage" class = "btn btn-success pull-left">\
                            שלחי הודעה להורים\
                        </a>\
                    </div>\
                </div>\
            </div>'
    $('#childModal').html(content);
    $('#childModal').modal('show');
}


function getChildInfo(child_id){
    $.ajax('/childInfo', {
        type: 'GET',
        data: { 
            'fmt': 'json',
            'child_id': child_id
        },
        success: showChildInfo
    });
}

function buildChild(child_data){
    var childRow = '<p>';
    childRow +='<strong>' + child_data.first_name + ' ' + child_data.last_name + '</strong>';
    childRow += ' לא הגיע לגן ' + child_data.days + ' ימים';
    childRow += '</p>';    
    return childRow;
}

//function showMissings(data){
//    missingsArr = JSON.parse(JSON.stringify(data));
//    if (data.length != 0){
//        console.log('should display missings');
//        var missingsText = '<div class="alert alert-info alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>';
//        for (var i = 0; i < missingsArr.length; i++) {
//            missingsText += buildChild(JSON.parse(missingsArr[i]));
//        }
//
//        missingsText += '</div>';
//        $('#forMissings').html(missingsText);
//    }
//    console.log(data);
//
//}
//
//function getMissings(){
//        $.ajax('/getMissings', {
//        type: 'GET',
//        data: {
//            'fmt': 'json',
//        },
//        success: showMissings
//    });
//}


